<?php
    include ("../init.php");
    $q_id = $_GET['q_id'];
    $sql = "SELECT * FROM hs_qoute WHERE q_id = '$q_id'";
    $qouteInfo = $db->queryUniqueObject($sql);
    $memberInfo = $db->queryUniqueObject('SELECT * FROM hs_member WHERE m_id='.$qouteInfo->m_id);
    
    $status = FALSE;
    
    $sql = "SELECT * FROM hs_qoute_product WHERE q_id=$q_id ORDER BY p_id";
    $rss = $db->query($sql);
    $productList = '';
    while ($line = $db->fetchNextObject($rss)){
        $sql = "SELECT 	p_style_number , p_type , p_name , p_detail FROM hs_product WHERE p_id ={$line->p_id}";
        $query_p = mysql_query($sql);
        $result_p = mysql_fetch_assoc($query_p);
        
        $p_type = '&nbsp;';
        $p_style_number = '&nbsp;';
        $p_name = '&nbsp;';
        $p_detail = '&nbsp;';
        if(trim($result_p['p_type'])!=''){
                $p_type = $result_p['p_type'];
        }
        if(trim($result_p['p_style_number'])!=''){
                $p_style_number = $result_p['p_style_number'];
        }
        if(trim($result_p['p_name'])!=''){
                $p_name = $result_p['p_name'];
        }
        if(trim($result_p['p_detail'])!=''){
                $p_detail = $result_p['p_detail'];
        }
        
            $productList .= <<<TBODY
                <tr class="product_list">
                    <td style="border:1px solid #666666;">{$p_type}</td>
                    <td style="border:1px solid #666666;">{$p_style_number}</td>
                    <td style="border:1px solid #666666;">{$p_name}</td>
                    <td style="border:1px solid #666666;">{$p_detail}</td>
                    <td style="border:1px solid #666666;" class="center">{$line->quantity}</td>
                </tr>
TBODY;
    }
?>
<style>
    *{
        font-size:13px;
        color:#000000;
        line-height:20px;
    }
    .text_bold{
        font-weight:bold;
    }
    .center{
        text-align:center;
    }
    .clear{
        clear:both;
        height:0;
        line-height:0;
    }
    
    #qoute_info_left{
        float:left;
        width:300px;
    }
    .qoute_info_left{
        clear:left;
        width:300px;
        color:#000000;
    }
    .qoute_info_left span{
        float:left;
        width:150px;
        text-align:right;
        padding-right:5px;
    }
    
    #qoute_info_right{
        float:left;
        width:500px;
    }
    .qoute_info_right{
        clear:left;
        width:500px;
        color:#000000;
    }
    .qoute_info_right span{
        float:left;
        width:100px;
        text-align:right;
        padding-right:5px;
    }
    .qoute_info_right span.address{
        float:left;
        width:100px;
        height:120px;
        text-align:right;
        padding-right:5px;
    }
    
    #product_list{
        width:800px;
        bqoute:1px solid #666666;
        margin-top:10px;
    }
    #product_list tr th , #product_list tr td{
        bqoute:1px solid #666666;
    }
</style>

<div id="qoute_info_left">
        <div class="qoute_info_left"><span class="text_bold"><?php _l('Date'); ?> : </span><?php echo date('d/m/Y',$qouteInfo->q_dateadd); ?></div>
        <div class="qoute_info_left"><span class="text_bold"><?php _l('Member'); ?> : </span><?php echo $memberInfo->m_name,' ',$memberInfo->m_name; ?></div>
        <div class="qoute_info_left"><span class="text_bold"><?php _l('Email'); ?> : </span><?php echo  $memberInfo->m_email; ?></div>
        <div class="qoute_info_left"><span class="text_bold"><?php _l('Phone'); ?> : </span><?php echo $memberInfo->m_phone; ?></div>
</div>

<div id="qoute_info_right">
        <div class="qoute_info_right"><span class="text_bold"><?php _l('Address'); ?> : </span><?php echo $memberInfo->m_address; ?></div>
        <div class="qoute_info_right"><?php echo $shipping; ?></div>
        <div class="qoute_info_right"><span class="text_bold"><?php _l('City'); ?> : </span><?php echo $memberInfo->m_city; ?></div>
        <div class="qoute_info_right"><span class="text_bold"><?php _l('State'); ?> : </span><?php echo $memberInfo->m_state; ?></div>
        <div class="qoute_info_right"><span class="text_bold"><?php _l('Country'); ?> : </span><?php echo $memberInfo->m_country; ?></div>
        <div class="qoute_info_right"><span class="text_bold"><?php _l('Zip/Postcode'); ?> : </span><?php echo $memberInfo->m_postcode; ?></div>
</div>
<div class="clear">&nbsp;</div>

<table id="product_list" style="border:1px solid #666666;">
    <tr>
        <th style="border:1px solid #666666;padding:5px 10px;">Type</th>
        <th style="border:1px solid #666666;padding:5px 10px;">Style Number</th>
        <th style="border:1px solid #666666;padding:5px 10px;">Name</th>
        <th style="border:1px solid #666666;padding:5px 10px;">Detail</th>
        <th style="border:1px solid #666666;width:100px;"><?php _l('quantity'); ?></th>
    </tr>
    <?php echo $productList; ?>
</table>